import hljs from 'highlight.js';
import { IconContext } from 'react-icons';
import { FcFile, FcFolder } from 'react-icons/fc';
async function getServerSideProps(context) {
const res = await fetch('http://localhost:3000/api' + context.resolvedUrl);
const data = await res.json();
return { props: { data } };
}
function MidSection(props) {
return (
{props.children}
);
}
function MainContentContainer(props) {
return (
{props.children}
);
}
function BreadCrumbTrail(props) {
const pathArray = props.pathArray;
const recursion = (acc) => {
if (acc.length === pathArray.length) {
return acc;
} else {
const subArray = pathArray.slice(0, acc.length + 1);
const breadCrumb = {
name: pathArray[acc.length],
href: '/' + subArray.join('/'),
};
const newAcc = acc.concat([breadCrumb]);
return recursion(newAcc);
}
};
const breadCrumbs = recursion([]);
return (
);
}
function DirectoryListing(props) {
return (
{props.resultContent.trees.map((item) => (
-
{item}
))}
{props.resultContent.blobs.map((item) => (
-
{item}
))}
);
}
function LineNos(props) {
const count = props.textBlob.split('\n').length;
const lineNos = [...Array(count).keys()].map((x) => x + 1).join('\n');
return (
{lineNos}
);
}
function CodeBlock(props) {
const highlightedHTML = hljs.highlightAuto(props.textBlob).value;
return (
);
}
function TextDisplayGrid(props) {
return (
);
}
function PageSubstance({ data }) {
switch (data.resultType) {
case 'treeContents':
return (
);
break;
case 'textBlob':
return (
);
break;
case 'binaryBlob':
return (
Binary content cannot be displayed.
);
break;
case 'error':
return (
Error:
{data.resultContent}
);
break;
}
}
function Main({ data }) {
return (
);
}
export { getServerSideProps };
export default Main;